package java101;

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;

public class TenKWords2 {

	public static void main(String[] args) {
		try {
			FileReader fileReader = new FileReader(
					"//Users//Meg//Downloads//10kwords.txt");
			BufferedReader bufferedReader = new BufferedReader(fileReader);
			String longestWord = "";
			for (int i = 0; i < 10000; i++) {
				String oneLine = bufferedReader.readLine();
				
				
				if (isWordAlphabetized(oneLine)){
					if (oneLine.length() > longestWord.length()){
						longestWord = oneLine;
					}
					if (oneLine.length() == 6){
						System.out.println(oneLine);
					}
						
				}
				
			}
//			System.out.println(longestWord);
			
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
		
		
	}


	public static boolean isWordAlphabetized(String word) {
		for (int i = 1; i < word.length(); i++) {
			if (word.charAt(i) <= word.charAt(i - 1)) {
				return false;
			}
		}
		return true;
	}

}
